Skip to content

Conversation

bramwelt
Copy link
Contributor

@bramwelt bramwelt commented Aug 5, 2025

This change ensures the https redirects for mailipit
aren't created when there is no https listener defined on the gateway.
and evaluates any non-empty string as true, and the include was
returning the string "false".

Generated with Cursor

Signed-off-by: Trevor Bramwell [email protected]

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 01:06
@bramwelt bramwelt requested review from emsearcy and a team as code owners August 5, 2025 01:06
Copy link

coderabbitai bot commented Aug 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Helm chart version bumped from 0.2.18 to 0.2.19. In the Mailpit HTTPRoute template, the conditional rendering now uses an explicit equality check against the string "true" for the included "lfx-platform.https-enabled" value.

Changes

Cohort / File(s) Summary
Mailpit HTTPRoute gating condition
charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml
Replaced a truthy conditional with an explicit eq comparison to string "true" for include "lfx-platform.https-enabled" within the and condition controlling HTTPRoute rendering.
Chart version bump
charts/lfx-platform/Chart.yaml
Updated version from 0.2.18 to 0.2.19.

Sequence Diagram(s)

sequenceDiagram
  participant Helm as Helm
  participant Tmpl as Template: https-redirect-httproute.yaml
  participant Inc as include "lfx-platform.https-enabled"
  participant Out as Rendered HTTPRoute

  Helm->>Tmpl: Render chart
  Tmpl->>Inc: Evaluate https-enabled
  Inc-->>Tmpl: "true" | "false" | other
  Tmpl->>Tmpl: Check eq(result, "true") and other conditions
  alt eq(...) is true
    Tmpl-->>Out: Emit HTTPRoute manifest
  else eq(...) is false
    Tmpl-->>Out: Skip emitting HTTPRoute
  end

  note over Tmpl: Conditional now uses explicit string equality check
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix: HTTPS Redirects Always Enabled" clearly describes the main problem being addressed in this changeset. The changes fix a conditional logic issue in the HTTPRoute template where HTTPS redirects were being created even when HTTPS was disabled, because the and operator was evaluating the string "false" as truthy. The title accurately captures the bug being fixed (redirects being always enabled when they shouldn't be) and aligns directly with the core change in the mailpit HTTPRoute template conditional logic.
Description Check ✅ Passed The PR description is clearly related to the changeset and provides meaningful context. It explains that HTTPS redirects for mailpit were being incorrectly created when no HTTPS listener was defined on the gateway, describes the root cause (the and operator evaluating non-empty strings as true with the include returning "false"), and explains what the fix accomplishes. The description directly corresponds to the changes made in the HTTPRoute template conditional logic.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bramwelt/fix-https-redirects

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb1b412 and 5b38272.

📒 Files selected for processing (2)
  • charts/lfx-platform/Chart.yaml (1 hunks)
  • charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • charts/lfx-platform/Chart.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml

🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where HTTPS redirect HTTPRoutes for Authelia and Mailpit were being created even when HTTPS was disabled. The issue occurred because Helm's and function evaluates any non-empty string as true, and the lfx-platform.https-enabled template was returning the string "false" instead of a boolean false.

  • Fixed conditional logic to properly check if HTTPS is enabled using string comparison
  • Added missing traefik.enabled condition to the authelia template for consistency
  • Ensures HTTPS redirects are only created when HTTPS is actually configured

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml Updated conditional to use string comparison for HTTPS check
charts/lfx-platform/templates/authelia/https-redirect-httproute.yaml Fixed HTTPS check and added missing traefik.enabled condition

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml (1)

4-4: Consider parsing the helper output as a boolean instead of string-matching
Relying on a literal string "true" couples every consumer to the helper’s exact output. A more robust pattern is:

{{ if and .Values.mailpit.enabled .Values.traefik.enabled (include "lfx-platform.https-enabled" . | fromYaml | default false) -}}

fromYaml coerces "true"/"false" to booleans, shielding you if the helper ever returns real YAML booleans or gets refactored.

charts/lfx-platform/templates/authelia/https-redirect-httproute.yaml (1)

4-4: Avoid duplicating complex conditions across components
Mailpit and Authelia now share almost identical guard clauses. Extracting a helper, e.g. {{- define "lfx-platform.enable-https-redirect" -}} … {{- end -}}, would centralise the logic and cut drift risk.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e312608 and cb1b412.

📒 Files selected for processing (2)
  • charts/lfx-platform/templates/authelia/https-redirect-httproute.yaml (1 hunks)
  • charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: MegaLinter
🔇 Additional comments (2)
charts/lfx-platform/templates/mailpit/https-redirect-httproute.yaml (1)

4-4: Explicit equality check fixes the unintended redirect creation
Changing the condition to eq ... "true" prevents the previous truthy string pit-fall, so the HTTPRoute now renders only when an HTTPS listener really exists.

charts/lfx-platform/templates/authelia/https-redirect-httproute.yaml (1)

4-4: Good addition of the Traefik gate and strict HTTPS check
The extra .Values.traefik.enabled guard plus the explicit "true" comparison close the loophole that rendered a redirect with no HTTPS listener.

jordane
jordane previously approved these changes Aug 5, 2025
This change ensures the https redirect for mailipit is only created when
there is a https listener defined on the gateway.

Generated with [Cursor](https://cursor.com/)

Signed-off-by: Trevor Bramwell <[email protected]>
Signed-off-by: Trevor Bramwell <[email protected]>
@bramwelt bramwelt merged commit 86c6bc8 into main Sep 29, 2025
4 checks passed
@bramwelt bramwelt deleted the bramwelt/fix-https-redirects branch September 29, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants